/* GUI CONVERTED from rsmrw.p (converter v1.76) Tue Apr  9 23:04:20 2002 */
/* rsmrw.p - Release Management Supplier Schedules                      */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.5.1.3 $                                                         */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92   BY: WUG *F110*            */
/* REVISION: 7.0    LAST MODIFIED: 03/23/92   BY: WUG *F312*            */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92   BY: WUG *F323*            */
/* REVISION: 7.2    LAST MODIFIED: 12/23/92   BY: WUG *G471*            */
/* REVISION: 7.3    LAST MODIFIED: 04/02/93   BY: WUG *G828*            */
/* REVISION: 7.3    LAST MODIFIED: 07/13/93   BY: WUG *GD42*            */
/* REVISION: 7.3    LAST MODIFIED: 10/31/94   BY: WUG *GN76*            */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan     */
/* REVISION: 8.6E   LAST MODIFIED: 07/10/98   BY: *H1LW* Surekha Joshi  */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown     */
/* REVISION: 9.1    LAST MODIFIED: 10/06/00   BY: *N0RT* Jean Miller    */
/* Old ECO marker removed, but no ECO header exists *F0PN*              */
/* $Revision: 1.5.1.3 $    BY: Ashwini G.           DATE: 03/26/02  ECO: *N1FG* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* UPDATE MRP DETAIL */

/* INCLUDE FILE SHARED VARIABLES */
{mfdeclre.i}

/* INCLUDE FILE FOR TRANSLATION GPLABEL FUNCTION */
{gplabel.i}

define input parameter order_nbr       as   character   no-undo.
define input parameter order_line      as   integer     no-undo.
define input parameter schedule_change like mfc_logical no-undo.

define variable req_schedule      as integer   no-undo initial 4.
define variable i                 as integer   no-undo.
define variable prior_cum_net_req as decimal   no-undo.
define variable cum_net_req       as decimal   no-undo.
define variable net_req           as decimal   no-undo.

for first pod_det
   fields (pod_cum_qty pod_curr_rlse_id pod_firm_days pod_line pod_nbr pod_part
           pod_site pod_type pod_um_conv)
   where pod_nbr  = order_nbr
     and pod_line = order_line
no-lock:
end. /* FOR FIRST pod_det */

if pod_type <> ""
then
   leave.

if schedule_change
then do:
   /* WE NEED TO COMPLETELY REFRESH SO DELETE EVERYTHING */
   for each mrp_det
      where mrp_dataset = "ss sch_mstr"
        and mrp_part    = pod_part
        and mrp_nbr     = pod_nbr
        and mrp_line    = string(pod_line)
   exclusive-lock:
      delete mrp_det.
   end. /* FOR EACH mrp_det */

   /* FLIP in_mstr REQUIRED FLAG TO YES */
   {inmrp.i
      &part=pod_part
      &site=pod_site}
end. /* IF schedule_change */

for first sch_mstr
   fields (sch_line sch_nbr sch_pcr_qty sch_pcs_date sch_rlse_id sch_type)
   where sch_type    = req_schedule
     and sch_nbr     = pod_nbr
     and sch_line    = pod_line
     and sch_rlse_id = pod_curr_rlse_id[req_schedule - 3]
no-lock:
end. /* FOR FIRST sch_mstr */

if pod_firm_days = 0
then
   leave.

if available sch_mstr
then do:

   assign
      i = 1
      prior_cum_net_req = max(sch_pcr_qty - pod_cum_qty[1],0).


   /* MRP WORKFILE UPDATE */
   /* PASS TERM DIRECTLY AS THE TENTH PARAMETER */
   {mfmrw.i "ss sch_mstr"
            pod_part
            pod_nbr
            string(pod_line)
            """"
            ?
            sch_pcs_date
            "(prior_cum_net_req * pod_um_conv)"
            "supply"
            SUPPLIER_SCHEDULES_PURCHASE_ORDER
            pod_site}

   for each schd_det
      fields (schd_cum_qty schd_date schd_fc_qual schd_line schd_nbr
              schd_rlse_id schd_type)
      where schd_type    = sch_type
        and schd_nbr     = sch_nbr
        and schd_line    = sch_line
        and schd_rlse_id = sch_rlse_id
   no-lock:
/*GUI*/ if global-beam-me-up then undo, leave.

      assign
         cum_net_req       = max(schd_cum_qty - pod_cum_qty[1],0)
         net_req           = cum_net_req - prior_cum_net_req
         prior_cum_net_req = cum_net_req.

      if schd_fc_qual = "f"
      then do:

         /* MRP WORKFILE UPDATE */
         /* PASS TERM DIRECTLY AS THE TENTH PARAMETER */
         {mfmrw.i "ss sch_mstr"
                  pod_part
                  pod_nbr
                  string(pod_line)
                  string(i)
                  ?
                  schd_date
                  "(net_req * pod_um_conv)"
                  "supply"
                  SUPPLIER_SCHEDULES_PURCHASE_ORDER
                  pod_site}
      end. /* IF schd_fc_qual = "f" */

      i = i + 1.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR EACH schd_det */
end. /* IF AVAILABLE sch_mstr */
